package linklist;


import java.util.ArrayList;

public class Solution234 {
    public boolean isPalindrome(ListNode head) {
        ArrayList<Integer> arrayList = new ArrayList<Integer>();
        while (head!=null){
            arrayList.add(head.val);
            head=head.next;
        }
        int listSize=arrayList.size();
        for (int i = 0; i < listSize/2; i++) {
            if (!arrayList.get(i).equals(arrayList.get(listSize - i - 1))) {
                return false;
            }
        }
        return true;
    }
}
